<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="css/base/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="css/base/Buttons.css" />
		<link rel="stylesheet" type="text/css" href="css/base/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/base/jqueryweui.css" />
		<style type="text/css">
			* {
				margin: 0px;
				padding: 0px;
				border: 0px;
			}
			
			body {
				background: #F7FAFC;
			}
			
			.logo {
				display: block;
				width: 100px;
				height: 100px;
				margin: auto;
				margin-top: 50px;
				margin-bottom: 10px;
				font-size: 100px;
				font-weight: bolder;
				color: #0F88EB;
			}
			
			.txt {
				display: block;
				text-align: center;
				height: 50px;
				line-height: 50px;
				font-size: 18px;
				color: #666666;
			}
			
			.mail {
				width: 90%;
				height: 50px;
				border: 1px solid #D5D5D5;
				margin: auto;
				line-height: 50px;
				text-align: center;
				outline: none;
				font-size: 16px;
				background: rgba(255, 255, 255, 1);
			}
			
			.mail:empty:before {
				content: attr(placeholder);
				font-size: 18px;
				color: #d5d5d5;
			}
			
			.mail:focus:before {
				content: none;
			}
			
			.password {
				display: block;
				width: 90%;
				height: 50px;
				border: 1px solid #D5D5D5;
				margin: 20px auto;
				line-height: 50px;
				text-align: center;
				outline: none;
				font-size: 16px;
				background: rgba(255, 255, 255, 1);
			}
			
			.button {
				display: block;
				width: 90%;
				margin: auto;
			}
			
			.login-reg {
				height: 50px;
				line-height: 70px;
				display: block;
				font-size: 14px;
				width: 90%;
				text-align: right;
			}
			
			a {
				color: #666666;
				text-decoration: none;
			}
		</style>
	</head>

	<body>
		<span class="logo Hui-iconfont Hui-iconfont-home"></span>
		<span class="txt">天津智能公共自行车</span>
		<div class="mail" id="login_text" placeholder='账号登录' contenteditable="true"></div>
		<input class="password" id="login_pwd" type="password" placeholder='密码' />
		<a class="button button-3d button-primary button-rounded login_click">登录</a>
		<span class="login-reg"><a href="register.html" >新用户注册</a></span>
	</body>
	<script src="js/base/av-min-2.1.2.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/base/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/base/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/base/vue.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		//接入leanCloud注册邮箱
		window.onload = function() {
			var APP_ID = 'hN1kSQf2DQ9awcJmwEmIIdVo-gzGzoHsz';
			var APP_KEY = 'aHCVjhhcyeerTEsKObkGSyd6';
			AV.init({
				appId: APP_ID,
				appKey: APP_KEY
			});
		}

		$(".login_click").click(function() {
			var email = $('#login_text').html();
			var pwd = $('#login_pwd').val();
			var query = new AV.Query('user_info');
			var cql = 'select * from user_info where email = "' + email + '" and Password = "' + pwd + '"';
			AV.Query.doCloudQuery(cql).then(function(data) {
				// results 即为查询结果，它是一个 AV.Object 数组
				var results = data.results;
				
				if (results.length == 0) {
					alert("账号或密码错误，请重新输入！")
				}else{
					console.log(results[0].id)
					sessionStorage.setItem("id",results[0].id)
					sessionStorage.setItem('email',results[0].attributes.email)
					sessionStorage.setItem('idCard',results[0].attributes.idCard)
					sessionStorage.setItem('phoneNumber',results[0].attributes.phoneNumber)
					sessionStorage.setItem('userName',results[0].attributes.userName)
					location.href ='personal.html'
				}
			}, function(error) {});

		})
	</script>

</html>